package frank.zou.study.jmock.customized.matcher;

import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

public class StringStartsWithMatcher extends TypeSafeMatcher<String> {

	private String prefix;
	
	public StringStartsWithMatcher(String prefix) { 
		this.prefix = prefix; 
	}
	
	@Override
	public boolean matchesSafely(String s) {
		return s.startsWith(prefix);
	}

	public void describeTo(Description description) {
		description.appendText("a string started with ").appendValue(prefix);
	}

//	@Factory
	public static Matcher<String> aStringStartedWith(String prefix) { 
		return new StringStartsWithMatcher(prefix);
	}
}
